import logging
from typing import Any

import requests

from const import ADDR

logger = logging.getLogger()

GROUP_SEND_URL = 'http://%s/sendGroupMessage' % ADDR
FRIEND_SEND_URL = 'http://%s/sendFriendMessage' % ADDR


def send_group_msg(session: str, group_id: str, msg_chain: list):
    params = {
        "sessionKey": session,
        "target": group_id,
        "messageChain": msg_chain
    }
    logger.info(requests.post(url=GROUP_SEND_URL, json=params).text)


def send_friend_msg(session: str, target_id: Any, msg_chain: list):
    params = {
        "sessionKey": session,
        "target": int(target_id),
        "messageChain": msg_chain
    }
    logger.info(requests.post(url=FRIEND_SEND_URL, json=params).text)
